package com.lkcg.demo.basedao;

import tk.mybatis.mapper.common.Mapper;

import java.io.Serializable;

/**
 * 只创建对表的增删改操作
 */
public interface BaseDAO<T, Pk extends Serializable> extends Mapper<T> {

    default int deleteWithVersion(T t) {
        int result = delete(t);
        if (result == 0) {
            throw new RuntimeException("删除失败!");
        }
        return result;
    }

    default int updateByPrimaryKeyWithVersion(T t) {
        int result = updateByPrimaryKey(t);
        if (result == 0) {
            throw new RuntimeException("更新失败!");
        }
        return result;
    }

}
